ostree-prepare-root: Error if realpath fails
authorWilliam Manley <will@williammanley.net>
Wed, 31 Aug 2016 16:07:17 +0000 (17:07 +0100)
committerAtomic Bot <atomic-devel@projectatomic.io>
Thu, 1 Sep 2016 20:17:58 +0000 (20:17 +0000)
I've seen it fail with musl which needs `/proc` to be mounted for it to
work.  The error messages we're rather confusing before.  At least this
now points to the right location.

Closes: #485
Approved by: cgwalters

src/switchroot/ostree-prepare-root.c

index d866f88edcd3ccc87470ab90e48aa65fddd50411..ea7333b56eba6dea447cf6c132d2637c5e15ff23 100644 (file)
@@ -174,17 +174,19 @@ pivot_root(const char * new_root, const char * put_old)
 int
 main(int argc, char *argv[])
 {
-  const char *root_mountpoint = NULL;
+  const char *root_mountpoint = NULL, *root_arg = NULL;
   char *deploy_path = NULL;
   char srcpath[PATH_MAX];
   struct stat stbuf;
 
   if (argc < 2)
-    root_mountpoint = "/";
+    root_arg = "/";
   else
-    root_mountpoint = argv[1];
+    root_arg = argv[1];
 
-  root_mountpoint = realpath (root_mountpoint, NULL);
+  root_mountpoint = realpath (root_arg, NULL);
+  if (root_mountpoint == NULL)
+    err (EXIT_FAILURE, "realpath(\"%s\")", root_arg);
   deploy_path = resolve_deploy_path (root_mountpoint);
 
   /* Work-around for a kernel bug: for some reason the kernel